package com.chuyangc.qdms.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * @author 欧楚杨
 */
@Configuration
@EnableSwagger2WebMvc
public class SwaggerConfig {
    @Bean
    public Docket docketTrans() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
//                .enable(b)
                .groupName("物流组")
                .select()
                .paths(PathSelectors.ant("/chuyangc/transport/**"))
//                .apis(RequestHandlerSelectors.basePackage("com.swaggerdemo.controller"))
                .build();
    }

    @Bean
    public Docket docketLogrec() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
//                .enable(b)
                .groupName("日志组")
                .select()
                .paths(PathSelectors.ant("/chuyangc/logrec/**"))
//                .apis(RequestHandlerSelectors.basePackage("com.swaggerdemo.controller"))
                .build();
    }

    private ApiInfo apiInfo() {
        Contact contact = new Contact("欧楚杨", "https://gitee.com/chuyangc/q-dms-data-mining-system", "chu_yang1025@163.com");
        return new ApiInfo("Q-DMS数据挖掘系统",
                "软件工程导论实训",
                "0.1 SNAPSHOT",
                "localhost",
                contact.getName(),
                "MIT",
                "");
    }
}

